import { getPatientConsultOrderDetailAPI } from "@/apis/consult"
import {   getPatientMedicineOrderDetailAPI } from "@/apis/order"
import type { GetPatientConsultOrderDetailData } from "@/types/consult"
import type { GetPatientConsultOrderDetailDatas, MedicineOrderDetail } from "@/types/order"
import { ref } from "vue"

/** 
 * 获取药品订单详情
 * */ 
export const useOrderDetail = (orderId: string) => {
  const orderDetail = ref<MedicineOrderDetail>()
  const loadOrderDetail = async () => {
    if (!orderId) return
    const res = await getPatientMedicineOrderDetailAPI(orderId)
    orderDetail.value = res.data
  }
  loadOrderDetail()
  // 可返回响应式数据
  return { orderDetail }
}

/**
 * 获取咨询订单详情
 * @param orderId 订单ID
 * @returns 订单详情
 */
export const useConsultOrderDetail = (orderId: string) => {
  const PersonOrderDetail = ref<GetPatientConsultOrderDetailData>()
  const loadOrderDetail = async () => {
    const res = await getPatientConsultOrderDetailAPI(orderId)
    // console.log(res);
    PersonOrderDetail.value = res.data
  }
  loadOrderDetail()
  return { PersonOrderDetail }
}
